package com.l.web.service.system.group;

import com.l.web.service.KeyUpdate;
import com.l.web.service.ResponseCode;
import com.l.web.service.ServiceSupport;
import com.l.web.service.ResponseInfo;
import org.apache.log4j.Logger;

public class GroupUpdateService extends ServiceSupport {

    private static final Logger LOGGER = Logger.getLogger(GroupUpdateService.class);
    private GroupDAO groupdao;

    public void setGroupdao(GroupDAO groupdao) {
        this.groupdao = groupdao;
    }

    public String execute() {
        KeyUpdate keyUpdate = this.getKeyUpdate(Group.class);
        LOGGER.debug("修改信息信息：" + keyUpdate);
        if (keyUpdate.check()) {
            int result = ResponseCode.FINISH;
            try {
                groupdao.update(keyUpdate);
            } catch (Exception e) {
                LOGGER.error("修改异常[" + keyUpdate + "]：" + e);
                result = ResponseCode.FAILURE;
            }
            ResponseInfo msg = new ResponseInfo(result);
            out(msg);
        } else {
            LOGGER.error("非法修改：" + keyUpdate);
            error(404);
        }
        return NONE;
    }
}
